﻿namespace fpsrpg
{
    using System;
    using System.Collections.Generic;
    using System.Text;

    using Microsoft.Xna.Framework;
    using Microsoft.Xna.Framework.Audio;
    using Microsoft.Xna.Framework.Content;
    using Microsoft.Xna.Framework.GamerServices;
    using Microsoft.Xna.Framework.Graphics;

    class Talents_Medic : Sprite
    {
        #region Fields

        public Texture2D circle;

        bool active;
        Rectangle CircleRectangle;
        Color[] CircleTextureData;
        Matrix CircleTransform;
        int Heal_value = 0;

        #endregion Fields

        #region Properties

        public Boolean Talent_active
        {
            get { return active; }
            set { active = value; }
        }

        #endregion Properties

        #region Methods

        public int Action_Healing_Circle(Player ThePlayerThatActivates, ContentManager TheContentmanager,SpriteBatch TheSpriteBatch, Color[] EnemyTextureData, Rectangle EnemyRectangle)
        {
            circle = TheContentmanager.Load<Texture2D>("medic_healing_circle_globe");

            Heal_value = 0;
            if (active == true)
            {
                CircleTextureData = new Color[circle.Width * circle.Height];
                circle.GetData(CircleTextureData);

                // Update the enemy's transform
                CircleTransform =
                        Matrix.CreateTranslation(new Vector3(-new Vector2(circle.Width / 2, circle.Height / 2), 0.0f)) *
                        Matrix.CreateRotationZ(0) *
                        Matrix.CreateTranslation(new Vector3(ThePlayerThatActivates.Position, 0.0f));

                //Enemy Bounding rectangle
                CircleRectangle = new Rectangle((int)ThePlayerThatActivates.Position.X - ((int)circle.Width / 2), (int)ThePlayerThatActivates.Position.Y - ((int)circle.Height / 2), circle.Width, circle.Height);

                //TheSpriteBatch.Draw(TheContentmanager.Load<Texture2D>("test_enemy_collision"), CircleRectangle, Color.White);
                if (Collision.IntersectPixels(CircleRectangle,CircleTextureData,EnemyRectangle,EnemyTextureData))
                    Heal_value = 1;
            }
            return Heal_value;
        }

        public void DrawCircle(Player ThePlayerThatActivates, ContentManager TheContentmanager,SpriteBatch TheSpriteBatch,int scale)
        {
            if (active == true)
                TheSpriteBatch.Draw(circle, new Rectangle((int)ThePlayerThatActivates.Position.X, (int)ThePlayerThatActivates.Position.Y, ThePlayerThatActivates.Size.Width * scale, ThePlayerThatActivates.Size.Height * scale), null, Color.White, 0, new Vector2(circle.Width / 2, circle.Height / 2), SpriteEffects.None, 1);
        }

        #endregion Methods
    }
}